<template>
	<view class="content">
		<!-- directive 指令 -->
		<view>资产：{{account}}</view>
		<view>资产：{{computedAccount}}</view>
		<view>喜欢的歌手是{{singer}}</view>
		<view>喜欢的歌手是：{{computedSinger}}</view>
		<input type="text" v-model="newName" />
		<button @click="addName">添加</button>
		<view>你要添加的名字{{newName}}</view>
		<view class="list-area">
			名字列表
			<view v-for="item in list" :key="index">
				{{item.name}}
			</view>
		</view>
		<view>
			<view v-for="item in repos":key='index'>
				{{item.description}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account:1234567877,
				singer:'梁非凡',
				newName:'',
				list:[{
					name:'周杰伦'
				}],
				repos:[]
			}
		},
		// data 二次加工
		computed:{
			computedSinger:function(){
				return this.singer.split('').reverse().join('');
			},
			computedAccount:function(){
				return (this.account/100000000).toFixed(2)+'亿元'
			}
		},
		onLoad() {
			uni.request({
				url:'https://api.githup.com/users/shunwuyu/repos',
				method:'GET',
				data:{},
				success:res=>{
					console.log(res);
					this.repos=res.data;
				},
				fail: () => {
					
				},
				complete:()=> {
					
				}
			})
		},
		methods: {
			addName(){
				let name=this.newName.trim();
				if(name){
					this.list=[
							...this.list,
							{name}
					]
				}
				this.newName='';
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
